const minCostClimbingStairs = cost => {
  let n = cost.length
  const arr = new Array(n + 1)
  arr[0] = arr[1] = 0
  for (let i = 2; i <= n; i++) {
    arr[i] = Math.min(arr[i - 1] + cost[i - 1], arr[i - 2] + cost[i - 2]);
  }
  return arr[n]
}

console.log(minCostClimbingStairs([1, 100, 1, 1, 1, 100, 1, 1, 100, 1]));